﻿#ifndef TASKITEMTREE_H
#define TASKITEMTREE_H

#include <QTreeWidget>
#include <QDomDocument>
#include "notify.h"
#include "commontreedelegate.h"
#include <QMouseEvent>
#include <QMenu>
#include <QCursor>
#include <QMimeData>
#include <QFileDialog>
#include<QString>
#include<QTextCodec>

#include "taskeditdialog.h"
#include "taskmanager.h"
#include "scriptitemtree.h"
#include"efficencydialog.h"
/**
 * @brief The TaskItemTree class 任务视图，按照任务对指令进行归类展示，支持对指令的批量操作
 */
class TaskItemTree : public QTreeWidget,public Notify
{
    Q_OBJECT
public:
    explicit TaskItemTree(QWidget *parent = 0);

    void loadItemFile(const QDomElement& node);
    void saveItemFile(QDomDocument doc,QDomElement node);

protected:
    virtual void mousePressEvent(QMouseEvent* e);

signals:
    void sig_updateTask(QString , QString, QString);
    void sig_selectCommand(const QString& sCommand);

private slots:
    void slot_addTask();
    void slot_loadSolution();
    void slot_saveSolution();
    void slot_editTaskItem();
    void slot_CalEfficency();
    void slot_Calnotfastpoint();
    void slot_removeTaskItem();
    // Notify interface
public:
    void updateTask(const QString &taskObj, const QString &cmdObj, const QString &scriptObj);
    void commandSelect(const QString &cmdObj);
    void removeTask(const QString &sTaskObj);

private:
    QTreeWidgetItem* isExistTopItem(QString sItemText,int role = Qt::WhatsThisRole);
    QTreeWidgetItem* getChildTreeItem(QTreeWidgetItem * parent,QString sItemText,int role = Qt::WhatsThisRole);
    void setCurSelectTask(const QString& curTaskName);
    QString mscurSelect;

    QVector<QTreeWidgetItem *> midregions;
};
#endif // TASKITEMTREE_H
